program Rectangl;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  Rectangle = class
    public
      a, b: Integer;
      procedure Square; virtual;
      procedure Update;
    private
      s: Integer;
  end;
  SmartRectangle = class (Rectangle)
    procedure sett(newa, newb: integer);
    procedure Square; override;
  end;

{ Rectangle }

procedure Rectangle.Square;
begin
  Writeln (s);
end;

procedure Rectangle.Update;
begin
  if a*b <> s then
  begin
    s:=a*b;
  end;
end;

{ SmartRectangle }

procedure SmartRectangle.sett(newa, newb: Integer);
begin
  a:=newa;
  b:=newb;
end;

procedure SmartRectangle.Square;
begin
  if a*b <> s then
  begin
    writeln ('You have forgotten to update S!');
  end else begin
    Writeln (s);
  end;
end;

var
  rect: SmartRectangle;

begin
  rect:= SmartRectangle.Create;
  rect.Sett(4,5);
  rect.Update;
  rect.Square;
  rect.Sett(2,5);
  rect.Square;
  Readln;
end.
